package redis

import (
	"fmt"
	"gitee.com/DonHz/qimi/bluebell/config"
	"github.com/go-redis/redis"
)

var client *redis.Client

func Init(cfg *config.RedisConfig) error {
	client = redis.NewClient(&redis.Options{
		Addr: fmt.Sprintf("%s:%d",
			cfg.Host,
			cfg.Port,
		),
		Password: cfg.Password,
		DB:       cfg.DB,
		PoolSize: cfg.PoolSize,
	})
	err:=client.Ping().Err()
	return err
}

func Close() {
	_ = client.Close()
}